﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DispatchAssist.BusinessLogical.Model
{
    public class CacheTemplate
    {
        private List<MsgTemplate> _list;

        public List<MsgTemplate> InitList
        {
            get
            {
                return _list;
            }
        }

        public CacheTemplate(List<MsgTemplate> list)
        {
            _list = list;
        }

        public MsgTemplate GetTemplateByPara(int Action,string TargetType)
        {

            if (string.IsNullOrEmpty(TargetType))
            {
                return _list.Where(f => f.AlertAction == Action).ToList()[0];
            }
            else
            {
                return _list.Where(f => (f.AlertAction == Action)&&(f.TargetType==TargetType)).ToList()[0];
            }
        }

        public string GetTemplateContentByPara(int Action, string TargetType)
        {
            try
            {
                MsgTemplate info = GetTemplateByPara(Action, TargetType);
                return info.MsgContent;
            }
            catch
            {
                return null;
            }
        }
    }
}
